package cn.cas.mango.controller;

import cn.cas.mango.dto.Message;
import cn.cas.mango.dto.param.HotListDetailParam;
import cn.cas.mango.dto.param.SearchHotParam;
import cn.cas.mango.dto.param.SummaryParam;
import cn.cas.mango.service.HotListDetailSearchService;
import cn.cas.mango.service.SearchHotService;
import cn.cas.mango.service.SummaryService;
import io.swagger.annotations.Api;
import org.elasticsearch.search.aggregations.metrics.Sum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/Ranking/")
@ResponseBody
@CrossOrigin
@Api(value="互联网接口", tags="热榜排序相关")
public class InternetSearch {
  @Autowired
  private HotListDetailSearchService searchService;

  @Autowired
  private SearchHotService searchHotService;

  @Autowired
  private SummaryService summaryService;

  @GetMapping
  public Message index() {
    return Message.builder().msg("").build();
  }

  // 聚类
  @RequestMapping(value = "hot/getAssembleHot", method = {RequestMethod.GET})
  public Message searchAdvanced(HotListDetailParam queryParam) {
    return searchService.cluster_vector(queryParam);
  }

  @RequestMapping(value = "hot/getAssembleHot", method = {RequestMethod.POST})
  public Message searchAdvancedPost2(@RequestBody HotListDetailParam queryParam)  {
    return searchService.cluster_vector(queryParam);
  }


  // 根据标题搜索
  @RequestMapping(value = "hot/searchHot", method = {RequestMethod.GET})
  public Message searchHot(SearchHotParam queryParam) {
    return searchHotService.searchHot(queryParam);
  }

  @RequestMapping(value = "hot/searchHot", method = {RequestMethod.POST})
  public Message searchHotPost2(@RequestBody SearchHotParam queryParam)  {
    return searchHotService.searchHot(queryParam);
  }

  //  提取摘要的接口
  @RequestMapping(value = "hot/summary", method = {RequestMethod.GET})
  public Message summary(SummaryParam summaryParam) {
    return summaryService.getSummary(summaryParam);
  }

  @RequestMapping(value = "hot/summary", method = {RequestMethod.POST})
  public Message summaryPost(@RequestBody SummaryParam summaryParam)  {
    return summaryService.getSummary(summaryParam);
  }

}
